function ajax({url, success, data={}, type="get", error, timeout=50}){
    let str = "";
    for(let i in data){
        str += `${i}=${data[i]}&`;
    }
    if(type === "get"){
        url += "?" + str + "_qft_=" + Date.now();
    }
    const xhr = new XMLHttpRequest();
    xhr.open(type, url, true);
    xhr.onload = function(){
        if(xhr.status === 200){
            if(success) success(xhr.responseText);
            error = null;
        }else{
            if(error) error(xhr.status);
        }
    }
    if(type === "get"){
        xhr.send()
    }else{
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xhr.send(str.slice(0,str.length-1));
    }
    setTimeout(() => {
        if(error){
            error("timeout");
            success = null;
        }
    }, timeout);
}